'use strict'
const db = uniCloud.database()
const dbCmd = db.command
exports.main = async (event, context) => {
	const collection = db.collection('rank')
	
	const limit = parseInt(event.queryStringParameters.limit) || 10
	const page = parseInt(event.queryStringParameters.page) || 1
	var total = await collection.count()
	var res = await collection.orderBy('threshold', 'desc').orderBy('create_date', 'desc').skip((page - 1) * limit).limit(limit).get()
	return {
		total: total.total,
		data: res.data
	}
	// return event
}
